<template>
  <div class="profile">
    <el-card>
      <template #header>
        <div class="card-header">
          <h2>个人中心</h2>
          <el-button type="primary" @click="router.push('/user/settings')">编辑资料</el-button>
        </div>
      </template>
      <div class="user-info">
        <el-avatar :size="100" :src="userInfo.avatar || 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'" />
        <div class="info-content">
          <h3>{{ userInfo.nickname || userInfo.username }}</h3>
          <p>用户名：{{ userInfo.username }}</p>
          <p>邮箱：{{ userInfo.email || '未设置' }}</p>
          <p>角色：{{ userInfo.role || '普通用户' }}</p>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'

const store = useStore()
const router = useRouter()

const userInfo = computed(() => store.getters['user/userInfo'] || {})
</script>

<style scoped>
.profile {
  max-width: 1200px;
  margin: 20px auto;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  margin: 0;
  font-size: 20px;
}

.user-info {
  display: flex;
  gap: 20px;
  padding: 20px;
}

.info-content h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.info-content p {
  margin: 5px 0;
  color: var(--text-secondary);
}
</style> 